n1 = 20;
n2 = 25;
alpha = 0.01
# x = rnorm(n1, mean=10, sd=1.3)
x =c(9.86096629610442, 9.18264281516444, 10.3235765516664, 11.4051266066213, 
     8.10298624327845, 9.31962587132744, 7.73046962933836, 10.0332066888344, 
     7.41894004484039, 10.9775296536421, 9.31602321059136, 9.90456087656471, 
     9.38959793322238, 10.1792200997273, 9.17969705993908, 10.5821567673205, 
     10.9743780442365, 7.26348588946446, 9.4621124298591, 11.1264898932391
)

# y = rnorm(n2, mean=5.25, sd=1.3)
y = c(12.1860211486881, 8.70187892542241, 11.1731451615096, 12.2550947105641, 
      12.299775206192, 11.7209572829004, 8.13150575275037, 12.3459979352252, 
      13.2006123864424, 13.4085495196399, 11.6604788914484, 9.19503287565123, 
      11.2410712506662, 12.3876007429898, 11.3578028363966, 9.71195894206987, 
      9.66122257462968, 11.7022010229522, 11.1707599603582, 10.0238034959677, 
      9.89290754673975, 10.9991016670874, 9.87563080672555, 10.1033229664995, 
      9.99098326411349)

t.test(x, y=y, paired = FALSE, var.equal = TRUE, alternative = "less", conf.level = 1-alpha)


#druha cast 
df = n1 + n2 - 2
Sxy = sqrt(((n1-1)*sd(x)^2 + (n2-1)*sd(y)^2)/df)
t = ((mean(x)-mean(y))/(Sxy*sqrt(1/n1+1/n2)))
pValue = 1 - pt(t, df=df, lower.tail = FALSE, log.p = FALSE)
qt = qt(p=1-alpha,df=df)
t
qt
pValue